//
//  DDAccountBalanceViewController.m
//  DingDongZP
//
//  Created by weily on 16/5/11.
//  Copyright © 2016年 iyhjiang.com. All rights reserved.
//

#import "DDAccountBalanceViewController.h"
#import "DDMeCell.h"
#import "DDBalanceDetailsViewController.h"
#import "DDChargeViewController.h"

@interface DDAccountBalanceViewController ()
{
    NSArray *_titleArray;
}
@end

@implementation DDAccountBalanceViewController

- (instancetype)init
{
    if (self = [super init]) {
        _titleArray = @[@[@"帐户余额",
                        @"充值",
                        @"提现"],
                        @[@"共享余额帐户",
                          @"银行卡",
                          @"发票抬头",
                          @"收货地址"]];
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"帐户余额";
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - table

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return _titleArray.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_titleArray[section] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CustomCellIdentifier = @"DDMeCell";
    
    DDMeCell *cell = (DDMeCell *)[tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"DDMeCell" owner:self options:nil] lastObject];
    }
    cell.iconImage.frame = CGRectZero;
    cell.titleLabel.text = _titleArray[indexPath.section][indexPath.row];
//    cell.subTitleLabel.hidden = indexPath.row != 3;
    
    switch (indexPath.section)
    {
        case 0: {
            switch (indexPath.row) {
                case 0: {
                    cell.subTitleLabel.text = @"888.9元(共享金额：0.00元)";
                    break;
                }
                case 1: {
                    cell.subTitleLabel.text = @"现在充值最低9折";
                    break;
                }
                case 2: {
                    cell.subTitleLabel.text = @"可体现金额：8888.9元";
                    break;
                }
                default:
                    break;
            }
            break;
        }
        case 1: {
            switch (indexPath.row)
            {
                case 0: {
                    cell.subTitleLabel.text = @"1个";
                    break;
                }
                case 1: {
                    cell.subTitleLabel.text = @"1张";
                    break;
                }
                case 2: {
                    cell.subTitleLabel.text = @"1个";
                    break;
                }
                case 3: {
                    cell.subTitleLabel.text = @"1个";
                    break;
                }
                default:
                    break;
            }
            break;
        }
        default:
            break;
    }
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    UIViewController *vc = nil;
    switch (indexPath.section)
    {
        case 0: {
            switch (indexPath.row) {
                case 0: {
                    ///	帐户额额
                    vc = [[DDBalanceDetailsViewController alloc] init];
                    break;
                }
                case 1: {
                    ///	充值
                    vc = [[DDChargeViewController alloc] init];
                    break;
                }
                case 2: {
                    ///	提现
                    break;
                }
                default:
                    break;
            }
            break;
        }
        case 1: {
            switch (indexPath.row)
            {
                case 0: {
                    ///	共享帐户
                    break;
                }
                case 1: {
                    ///	银行卡
                    break;
                }
                case 2: {
                    ///	发票抬头
                    break;
                }
                case 3: {
                    ///	收货地址
                    break;
                }
                default:
                    break;
            }
            break;
        }
        default:
            break;
    }
    if (vc) {
        [self.navigationController pushViewController:vc animated:YES];
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 20;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
